package com.cooper.scraper.show;

import com.cooper.android.comm.GalleryTile;
import com.cooper.android.comm.Resource;
import com.cooper.scraper.R;

import android.content.Context;
import android.view.Display;
import android.view.ViewGroup.LayoutParams;
import android.widget.Gallery;
import android.widget.RelativeLayout;

public class TileGalleryViewFactory<T extends Resource> extends GalleryFanartShow<T> {

	public TileGalleryViewFactory(Context context, Display display,
			FanartViewStrategy<T> fanartStrategy,FanartSizeStrategy fanartSize) {
		super(context, display, fanartStrategy,fanartSize);
	}

	@Override
	public Gallery getAdapterView(Context context, float fanartWidth,
			float fanartHeight) {
		GalleryTile gallery = new GalleryTile(context);
		gallery.setBackgroundResource(R.drawable.showcase);
		gallery.setSpacing(3);
		gallery.setFadingEdgeLength(0);
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				LayoutParams.FILL_PARENT,
				(int) ((fanartHeight + fanartHeight / 3) * gallery
						.getZoomScale()));
		lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
		gallery.setLayoutParams(lp);

		return gallery;
	}
	
	@Override
	public void destroy() {
		super.destroy();
	}

	@Override
	protected FanartImgStrategy getFanartImgStrategy() {
		return CrystalFanartImgStrategy.getInstance();
	}

}
